package com.aspose.cells;

import java.util.ArrayList;

class zyq {
   private zaau a;
   private zyq.zd[] b;
   private zyq.zc c;
   private zyq.zi d;

   zyq(zaau var1) {
      this.a = var1;
      this.b = new zyq.zd[var1.b.length];
      this.c = new zyq.zc();
      this.d = new zyq.zi();
   }

   void a(int var1, int var2, int var3, int var4) {
      if (this.a(var1)) {
         if (var2 == this.a.a.getIndex()) {
            this.c.a(var3, var4, zyi.a(var2, var1));
         } else {
            this.a.a.c().get(var2).getCells().b.e.c.a(var3, var4, zyi.a(this.a.a.getIndex(), var1));
         }

         this.b[var1].a(Cell.a(var2, var3, var4));
      }
   }

   void a(int var1, int var2, int var3, int var4, int var5, int var6) {
      if (this.a(var1)) {
         zyq.zf var7;
         if (var2 == this.a.a.getIndex()) {
            var7 = this.d.a(var3, (short)var4, var5, (short)var6, zyi.a(var2, var1));
         } else {
            var7 = this.a.a.c().get(var2).getCells().b.e.d.a(var3, (short)var4, var5, (short)var6, zyi.a(this.a.a.getIndex(), var1));
         }

         this.b[var1].a(var2, var3, var7);
      }
   }

   void a(zyi var1) {
      if (var1.a < this.b.length && this.b[var1.a] != null) {
         this.b[var1.a].a(this, var1);
         this.b[var1.a] = null;
      }

   }

   ArrayList a(int var1, int var2) {
      zyq.za var3 = new zyq.za(this.a.a.c());
      zyq.zj var4 = this.c.a(var1);
      if (var4 != null) {
         var4.a(var2, var3);
      }

      if (this.d.b() > 0) {
         this.d.a(var1, (short)var2, var3);
      }

      return var3.a();
   }

   void b(int var1, int var2) {
      zyq.zb var3 = new zyq.zb(this.a.a.c());
      zyq.zj var4 = this.c.a(var1);
      if (var4 != null) {
         var4.a(var2, var3);
      }

      if (this.d.b() > 0) {
         this.d.a(var1, (short)var2, var3);
      }

   }

   private boolean a(int var1) {
      if (var1 < this.b.length) {
         if (this.b[var1] == null) {
            this.b[var1] = new zyq.ze();
            return true;
         } else {
            return this.b[var1].a();
         }
      } else {
         zyq.zd[] var2 = new zyq.zd[this.a.b.length];
         System.arraycopy(this.b, 0, var2, 0, this.b.length);
         this.b = var2;
         this.b[var1] = new zyq.ze();
         return true;
      }
   }

   private class za implements zyq.zh {
      private ArrayList b = new ArrayList();
      private WorksheetCollection c;

      za(WorksheetCollection var2) {
         this.c = var2;
      }

      ArrayList a() {
         return this.b;
      }

      public void a(long var1) {
         Cells var3 = this.c.get(zyi.a(var1)).getCells();
         zyi var4 = var3.b.a(zyi.b(var1));
         Cell var5 = var3.checkCell(var4.e, var4.f);
         if (var5 != null && var5.c.d == var4) {
            com.aspose.cells.b.a.a.ze.a(this.b, (Object)var5);
         } else {
            var3.b.b(var4.a);
         }
      }
   }

   private class zb implements zyq.zh {
      private WorksheetCollection b;

      zb(WorksheetCollection var2) {
         this.b = var2;
      }

      public void a(long var1) {
         zaau var3 = this.b.get(zyi.a(var1)).getCells().b;
         zyi var4 = var3.a(zyi.b(var1));
         if (var4.c() == 2) {
            var4.a((byte)0);
            var3.e.b(var4.e, var4.f);
         }

      }
   }

   private interface zh {
      void a(long var1);
   }

   private class zg {
      int a;
      int b;
      zyq.zf c;

      zg(int var2, int var3, zyq.zf var4) {
         this.a = var2;
         this.b = var3;
         this.c = var4;
      }
   }

   private class ze extends zyq.zd {
      private int e;
      private int f;

      private ze() {
         super(null);
      }

      public void a(zyq var1, zyi var2) {
         int var3 = var1.a.a.getIndex();
         WorksheetCollection var4 = var1.a.a.c();
         long var5 = zyi.a(var3, var2.a);
         if (this.e > 0) {
            for(int var10 = this.e - 1; var10 > -1; --var10) {
               long var7 = this.a[var10];
               int var9 = Cell.a(var7);
               if (var3 == var9) {
                  var1.c.b(Cell.b(var7), Cell.c(var7), var5);
               } else {
                  var4.get(var9).getCells().b.e.c.b(Cell.b(var7), Cell.c(var7), var5);
               }
            }
         }

         if (this.f > 0) {
            for(int var8 = this.f - 1; var8 > -1; --var8) {
               zyq.zg var11 = this.b[var8];
               if (var11.c.b(var5)) {
                  var4.get(var11.a).getCells().b.e.d.a(var11.b, var11.c);
               }
            }
         }

      }

      public boolean a() {
         return true;
      }

      public void a(long var1) {
         switch(this.e) {
         case 0:
            this.a = new long[]{var1, 0L};
            this.e = 1;
            return;
         case 1:
            if (this.a[0] > var1) {
               this.a[1] = this.a[0];
               this.a[0] = var1;
               this.e = 2;
            } else if (this.a[0] < var1) {
               this.a[1] = var1;
               this.e = 2;
            }

            return;
         default:
            int var3 = com.aspose.cells.b.a.za.a(this.a, 0, this.e, var1);
            if (var3 <= -1) {
               var3 = -var3 - 1;
               if (this.e == this.a.length) {
                  long[] var4 = new long[this.e << 1];
                  if (var3 > 0) {
                     System.arraycopy(this.a, 0, var4, 0, var3);
                  }

                  if (var3 < this.e) {
                     System.arraycopy(this.a, var3, var4, var3 + 1, this.e - var3);
                  }

                  this.a = var4;
               } else if (var3 < this.e) {
                  System.arraycopy(this.a, var3, this.a, var3 + 1, this.e - var3);
               }

               this.a[var3] = var1;
            }
         }
      }

      public void a(int var1, int var2, zyq.zf var3) {
         zyq.zg var4;
         switch(this.f) {
         case 0:
            this.b = new zyq.zg[]{zyq.this.new zg(var1, var2, var3), null};
            this.f = 1;
            return;
         case 1:
            var4 = this.b[0];
            if (var4.a == var1 && var4.b == var2 && var4.c == var3) {
               return;
            }

            this.b[1] = zyq.this.new zg(var1, var2, var3);
            this.f = 2;
            return;
         default:
            for(int var5 = this.f - 1; var5 > -1; --var5) {
               var4 = this.b[var5];
               if (var4.a == var1 && var4.b == var2 && var4.c == var3) {
                  return;
               }
            }

            if (this.f == this.b.length) {
               zyq.zg[] var6 = new zyq.zg[this.f << 1];
               System.arraycopy(this.b, 0, var6, 0, this.f);
               this.b = var6;
            }

            this.b[this.f] = zyq.this.new zg(var1, var2, var3);
            ++this.f;
         }
      }

      // $FF: synthetic method
      ze(Object var2) {
         this();
      }
   }

   private class zd {
      long[] a;
      zyq.zg[] b;

      private zd() {
      }

      public void a(zyq var1, zyi var2) {
         int var3 = var1.a.a.getIndex();
         WorksheetCollection var4 = var1.a.a.c();
         long var5 = zyi.a(var3, var2.a);
         if (this.a != null) {
            for(int var10 = this.a.length - 1; var10 > -1; --var10) {
               long var7 = this.a[var10];
               int var9 = Cell.a(var7);
               if (var3 == var9) {
                  var1.c.b(Cell.b(var7), Cell.c(var7), var5);
               } else {
                  var4.get(var9).getCells().b.e.c.b(Cell.b(var7), Cell.c(var7), var5);
               }
            }
         }

         if (this.b != null) {
            for(int var8 = 0; var8 < this.b.length; ++var8) {
               zyq.zg var11 = this.b[var8];
               if (var11.c.b(var5)) {
                  var4.get(var11.a).getCells().b.e.d.a(var11.b, var11.c);
               }
            }
         }

      }

      public boolean a() {
         return false;
      }

      public void a(long var1) {
         throw new CellsException(5, "Invalid logic for formula pool, the formula pool has been built.");
      }

      public void a(int var1, int var2, zyq.zf var3) {
         throw new CellsException(5, "Invalid logic for formula pool, the formula pool has been built.");
      }

      // $FF: synthetic method
      zd(Object var2) {
         this();
      }
   }

   private class zf {
      int a;
      short b;
      short c;
      int d = 0;
      long[] e = new long[2];

      public zf(int var2, short var3, short var4, long var5) {
         this.a = var2;
         this.b = var3;
         this.c = var4;
         this.d = 1;
         this.e[0] = var5;
      }

      public void a(long var1) {
         switch(this.d) {
         case 0:
            this.d = 1;
            this.e[0] = var1;
            return;
         case 1:
            if (this.e[0] == var1) {
               return;
            }

            this.d = 2;
            this.e[1] = var1;
            return;
         default:
            int var3 = com.aspose.cells.b.a.za.a(this.e, 0, this.d, var1);
            if (var3 <= -1) {
               var3 = -var3 - 1;
               if (this.d == this.e.length) {
                  long[] var4 = new long[this.d << 1];
                  if (var3 > 0) {
                     System.arraycopy(this.e, 0, var4, 0, var3);
                  }

                  if (var3 < this.d) {
                     System.arraycopy(this.e, var3, var4, var3 + 1, this.d - var3);
                  }

                  this.e = var4;
               } else if (var3 < this.d) {
                  System.arraycopy(this.e, var3, this.e, var3 + 1, this.d - var3);
               }

               ++this.d;
               this.e[var3] = var1;
            }
         }
      }

      public boolean b(long var1) {
         switch(this.d) {
         case 0:
            return true;
         case 1:
            if (this.e[0] != var1) {
               return false;
            }

            this.d = 0;
            return true;
         default:
            int var3 = com.aspose.cells.b.a.za.a(this.e, 0, this.d, var1);
            if (var3 < 0) {
               return false;
            } else {
               --this.d;
               System.arraycopy(this.e, var3 + 1, this.e, var3, this.d - var3);
               return false;
            }
         }
      }

      public void a(zyq.zh var1) {
         for(int var2 = 0; var2 < this.d; ++var2) {
            var1.a(this.e[var2]);
         }

      }
   }

   private class zi implements zahb {
      private int b;
      private int[] c;
      private int[] d;
      private zyq.zf[][] e;

      private zi() {
         this.b = 0;
         this.c = new int[16];
         this.d = new int[16];
         this.e = new zyq.zf[16][];
      }

      public int b() {
         return this.b;
      }

      public int c(int var1) {
         return this.c[var1];
      }

      public zyq.zf a(int var1, short var2, int var3, short var4, long var5) {
         boolean var7 = true;
         int var12;
         switch(this.b) {
         case 0:
            this.b = 1;
            this.c[0] = var1;
            this.d[0] = 1;
            this.e[0] = new zyq.zf[]{zyq.this.new zf(var3, var2, var4, var5), null};
            return this.e[0][0];
         case 1:
            if (this.c[0] < var1) {
               this.b = 2;
               this.c[1] = var1;
               this.d[1] = 1;
               this.e[1] = new zyq.zf[]{zyq.this.new zf(var3, var2, var4, var5), null};
               return this.e[1][0];
            }

            if (this.c[0] > var1) {
               this.b = 2;
               this.c[1] = this.c[0];
               this.d[1] = this.d[0];
               this.e[1] = this.e[0];
               this.c[0] = var1;
               this.d[0] = 1;
               this.e[0] = new zyq.zf[]{zyq.this.new zf(var3, var2, var4, var5), null};
               return this.e[0][0];
            }

            var12 = 0;
            break;
         default:
            var12 = zkd.a(this, var1, 0, this.b - 1);
         }

         if (var12 <= -1) {
            var12 = -var12 - 1;
            if (this.b == this.c.length) {
               int[] var13 = new int[this.b << 1];
               int[] var14 = new int[var13.length];
               zyq.zf[][] var15 = new zyq.zf[var13.length][];
               if (var12 > 0) {
                  System.arraycopy(this.c, 0, var13, 0, var12);
                  System.arraycopy(this.d, 0, var14, 0, var12);
                  System.arraycopy(this.e, 0, var15, 0, var12);
               }

               if (var12 < this.b) {
                  System.arraycopy(this.c, var12, var13, var12 + 1, this.b - var12);
                  System.arraycopy(this.d, var12, var14, var12 + 1, this.b - var12);
                  System.arraycopy(this.e, var12, var15, var12 + 1, this.b - var12);
               }

               this.c = var13;
               this.d = var14;
               this.e = var15;
            } else if (var12 < this.b) {
               System.arraycopy(this.c, var12, this.c, var12 + 1, this.b - var12);
               System.arraycopy(this.d, var12, this.d, var12 + 1, this.b - var12);
               System.arraycopy(this.e, var12, this.e, var12 + 1, this.b - var12);
            }

            ++this.b;
            this.c[var12] = var1;
            this.d[var12] = 1;
            this.e[var12] = new zyq.zf[]{zyq.this.new zf(var3, var2, var4, var5), null};
            return this.e[var12][0];
         } else {
            zyq.zf[] var8 = this.e[var12];
            int var10 = this.d[var12];
            zyq.zf var9;
            if (var10 == 1) {
               var9 = var8[0];
               if (var9.b == var2 && var9.a == var3 && var9.c == var4) {
                  var9.a(var5);
                  return var9;
               }
            } else {
               for(int var11 = var10 - 1; var11 > -1; --var11) {
                  var9 = var8[var11];
                  if (var9.b == var2 && var9.a == var3 && var9.c == var4) {
                     var9.a(var5);
                     return var9;
                  }
               }
            }

            if (var10 == var8.length) {
               zyq.zf[] var16 = new zyq.zf[var10 << 1];
               System.arraycopy(var8, 0, var16, 0, var10);
               this.e[var12] = var16;
               var8 = var16;
            }

            var8[var10] = zyq.this.new zf(var3, var2, var4, var5);
            ++this.d[var12];
            return var8[var10];
         }
      }

      public void a(int var1, zyq.zf var2) {
         boolean var3 = true;
         int var7;
         switch(this.b) {
         case 0:
            return;
         case 1:
            if (this.c[0] != var1) {
               return;
            }

            var7 = 0;
            break;
         default:
            var7 = zkd.a(this, var1, 0, this.b - 1);
         }

         if (var7 >= 0) {
            zyq.zf[] var4 = this.e[var7];
            int var5 = this.d[var7];
            if (var5 == 1) {
               if (var4[0] == var2) {
                  --this.b;
                  System.arraycopy(this.c, var7 + 1, this.c, var7, this.b - var7);
                  System.arraycopy(this.d, var7 + 1, this.d, var7, this.b - var7);
                  System.arraycopy(this.e, var7 + 1, this.e, var7, this.b - var7);
                  this.e[this.b] = null;
               }

            } else {
               for(int var6 = var5 - 1; var6 > -1; --var6) {
                  if (var4[var6] == var2) {
                     --var5;
                     --this.d[var7];
                     System.arraycopy(var4, var6 + 1, var4, var6, var5 - var6);
                     var4[var5] = null;
                     return;
                  }
               }

            }
         }
      }

      public void a(int var1, short var2, zyq.zh var3) {
         if (this.b >= 1) {
            for(int var7 = 0; var7 < this.b; ++var7) {
               if (this.c[var7] > var1) {
                  return;
               }

               int var6 = this.d[var7];
               if (var6 >= 1) {
                  zyq.zf[] var4 = this.e[var7];

                  for(int var8 = 0; var8 < var6; ++var8) {
                     zyq.zf var5 = var4[var8];
                     if (var5.a >= var1 && var5.b <= var2 && var5.c >= var2) {
                        var5.a(var3);
                     }
                  }
               }
            }

         }
      }

      // $FF: synthetic method
      zi(Object var2) {
         this();
      }
   }

   private class zj implements zahb {
      private int b;
      private short[] c;
      private int[] d;
      private long[][] e;

      private zj() {
         this.b = 0;
         this.c = new short[2];
         this.d = new int[2];
         this.e = new long[2][];
      }

      public int b() {
         return this.b;
      }

      public int c(int var1) {
         return this.c[var1];
      }

      public void a(int var1, long var2) {
         int var4;
         if (this.b < 1) {
            ++this.b;
            var4 = 0;
         } else {
            var4 = zkd.a(this, var1, 0, this.b - 1);
            if (var4 > -1) {
               long[] var9 = this.e[var4];
               int var10 = this.d[var4];
               int var11 = com.aspose.cells.b.a.za.a(var9, 0, var10, var2);
               if (var11 > -1) {
                  return;
               }

               var11 = -var11 - 1;
               if (var10 == var9.length) {
                  long[] var8 = new long[var10 << 1];
                  if (var11 > 0) {
                     System.arraycopy(var9, 0, var8, 0, var11);
                  }

                  if (var11 < var10) {
                     System.arraycopy(var9, var11, var8, var11 + 1, var10 - var11);
                  }

                  this.e[var4] = var8;
                  var9 = var8;
               } else if (var11 < var10) {
                  System.arraycopy(var9, var11, var9, var11 + 1, var10 - var11);
               }

               this.d[var4] = var10 + 1;
               var9[var11] = var2;
               return;
            }

            var4 = -var4 - 1;
            if (this.c.length == this.b) {
               short[] var5 = new short[this.b << 1];
               int[] var6 = new int[var5.length];
               long[][] var7 = new long[var5.length][];
               if (var4 > 0) {
                  System.arraycopy(this.c, 0, var5, 0, var4);
                  System.arraycopy(this.d, 0, var6, 0, var4);
                  System.arraycopy(this.e, 0, var7, 0, var4);
               }

               if (var4 < this.b) {
                  System.arraycopy(this.c, var4, var5, var4 + 1, this.b - var4);
                  System.arraycopy(this.d, var4, var6, var4 + 1, this.b - var4);
                  System.arraycopy(this.e, var4, var7, var4 + 1, this.b - var4);
               }

               this.c = var5;
               this.d = var6;
               this.e = var7;
            } else if (var4 < this.b) {
               System.arraycopy(this.c, var4, this.c, var4 + 1, this.b - var4);
               System.arraycopy(this.d, var4, this.d, var4 + 1, this.b - var4);
               System.arraycopy(this.e, var4, this.e, var4 + 1, this.b - var4);
            }

            ++this.b;
         }

         this.c[var4] = (short)var1;
         this.d[var4] = 1;
         this.e[var4] = new long[]{var2, 0L};
      }

      public boolean b(int var1, long var2) {
         int var4 = zkd.a(this, var1, 0, this.b - 1);
         if (var4 < 0) {
            return false;
         } else {
            int var5 = this.d[var4];
            if (var5 > 1) {
               long[] var6 = this.e[var4];
               int var7 = com.aspose.cells.b.a.za.a(var6, 0, var5, var2);
               if (var7 > -1) {
                  --var5;
                  this.d[var4] = var5;
                  if (var7 < var5) {
                     System.arraycopy(var6, var7 + 1, var6, var7, var5 - var7);
                  }

                  return true;
               }
            } else if (this.e[var4][0] == var2) {
               --this.b;
               if (var4 < this.b) {
                  System.arraycopy(this.e, var4 + 1, this.e, var4, this.b - var4);
                  System.arraycopy(this.d, var4 + 1, this.d, var4, this.b - var4);
               }

               this.e[this.b] = null;
               return true;
            }

            return false;
         }
      }

      public void a(int var1, zyq.zh var2) {
         if (this.b >= 1) {
            int var3 = zkd.a(this, var1, 0, this.b - 1);
            if (var3 >= 0) {
               long[] var4 = this.e[var3];

               for(int var5 = this.d[var3] - 1; var5 > -1; --var5) {
                  var2.a(var4[var5]);
               }

            }
         }
      }

      // $FF: synthetic method
      zj(Object var2) {
         this();
      }
   }

   private class zc implements zahb {
      private int b;
      private int[] c;
      private zyq.zj[] d;

      private zc() {
         this.b = 0;
         this.c = new int[16];
         this.d = new zyq.zj[16];
      }

      public int b() {
         return this.b;
      }

      public int c(int var1) {
         return this.c[var1];
      }

      public void a(int var1, int var2, long var3) {
         if (this.b < 1) {
            ++this.b;
            this.c[0] = var1;
            this.d[0] = zyq.this.new zj();
            this.d[0].a(var2, var3);
         } else {
            int var5 = zkd.a(this, var1, 0, this.b - 1);
            if (var5 > -1) {
               this.d[var5].a(var2, var3);
            } else {
               var5 = -var5 - 1;
               if (this.c.length == this.b) {
                  int[] var6 = new int[this.b << 1];
                  zyq.zj[] var7 = new zyq.zj[var6.length];
                  if (var5 > 0) {
                     System.arraycopy(this.c, 0, var6, 0, var5);
                     System.arraycopy(this.d, 0, var7, 0, var5);
                  }

                  if (var5 < this.b) {
                     System.arraycopy(this.c, var5, var6, var5 + 1, this.b - var5);
                     System.arraycopy(this.d, var5, var7, var5 + 1, this.b - var5);
                  }

                  this.c = var6;
                  this.d = var7;
               } else if (var5 < this.b) {
                  System.arraycopy(this.c, var5, this.c, var5 + 1, this.b - var5);
                  System.arraycopy(this.d, var5, this.d, var5 + 1, this.b - var5);
               }

               ++this.b;
               this.c[var5] = var1;
               this.d[var5] = zyq.this.new zj();
               this.d[var5].a(var2, var3);
            }
         }
      }

      public void b(int var1, int var2, long var3) {
         if (this.b >= 1) {
            int var5 = zkd.a(this, var1, 0, this.b - 1);
            if (var5 >= 0) {
               if (this.d[var5].b(var2, var3) && this.d[var5].b() < 1) {
                  --this.b;
                  if (var5 < this.b) {
                     System.arraycopy(this.c, var5 + 1, this.c, var5, this.b - var5);
                     System.arraycopy(this.d, var5 + 1, this.d, var5, this.b - var5);
                  }

                  this.d[this.b] = null;
               }

            }
         }
      }

      public zyq.zj a(int var1) {
         if (this.b < 1) {
            return null;
         } else {
            int var2 = zkd.a(this, var1, 0, this.b - 1);
            return var2 < 0 ? null : this.d[var2];
         }
      }

      // $FF: synthetic method
      zc(Object var2) {
         this();
      }
   }
}
